package com.itheima.list.增强for.学生类练习;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo {
    public static void main(String[] args) {

        ArrayList<Student> list=new ArrayList<>();

        Student s1=new Student("小皮",23);
        Student s2=new Student("小正",25);
        Student s3=new Student("小贾",26);
        list.add(s1);
        list.add(s2);
        list.add(s3);


        Iterator<Student> ite  = list.iterator();

       xHa(ite);
        System.out.println("--------");
      xHb(list);
        System.out.println("--------");
        for (Student stu2 : list) {
            System.out.println(stu2);
        }


    }

    public static void xHb(ArrayList<Student> list) {

        for (Student stu1 : list) {
            System.out.println(stu1);
        }
    }

    public static void xHa(Iterator<Student> ite) {
        while (ite.hasNext()){
           Student s=ite.next();
            System.out.println(s);
        }
    }
}
